<template>
	<view class="course-page-box">
		<z-paging ref="paging" v-model="courseList" @query="getTeacherCourseList" :safe-area-inset-bottom="true">
			<view class="course-list">
				<view class="course-item" v-for="( item, index ) in courseList" :key="index">
					<view class="item-top">
						<view class="course-title">{{item.teacher.name}}</view>
						<view class="course-time">{{item.date}}</view>
					</view>
					<view class="item-bottom">
						<view class="bottom-info">
							<text class="label">学校：</text>
							<text class="value">{{item.school.title}}</text>
						</view>
						<view class="bottom-info">
							<text class="label">课程：</text>
							<text class="value">{{item.course.title}}</text>
						</view>
						<view class="bottom-info">
							<text class="label">授课老师：</text>
							<text class="value">{{item.teacher.name}}</text>
						</view>
						<view class="bottom-info">
							<text class="label">学期：</text>
							<text class="value">{{item.term.title}}</text>
						</view>
						<view class="bottom-info">
							<text class="label">上课人数：</text>
							<text class="value">{{item.banji.student_num}}人</text>
						</view>
						<view class="bottom-info">
							<text class="label">上课地点：</text>
							<text class="value">{{item.course.place}}</text>
						</view>
						<view class="bottom-info">
							<text class="label">上课时间：</text>
							<text class="value">第{{item.schedule.num}}节({{item.schedule.class_time}})</text>
						</view>
						<view class="bottom-info">
							<text class="label">班级：</text>
							<text class="value">{{item.banji.title}}</text>
						</view>
					</view>
				</view>
			</view>
		</z-paging>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				schoolId: '', // 学校ID
				courseId: '', // 课程ID
				courseList: [], // 课程列表
			}
		},
		onLoad(options) {
			if (options && options.courseId) {
				this.schoolId = options.schoolId
				this.courseId = options.courseId
				uni.setNavigationBarTitle({
					title: options.title
				})
			}
		},
		methods: {
			getTeacherCourseList(pageNo, pageSize) {
				this.$Api.user.getTeacherCourseList({
					page: pageNo,
					limit: pageSize,
					school_id: this.schoolId,
					course_id: this.courseId,
				}).then(res => {
					this.$refs.paging.complete(res.data.data);
				})
			},
		}
	}
</script>

<style lang="scss" scoped>
	.course-page-box {
		min-height: 100vh;
		background: #f5f6fa;
	}

	.course-list {
		padding: 20rpx;
	}

	.course-item {
		background: #fff;
		box-shadow: 0rpx 4rpx 8rpx 0rpx rgba(0, 0, 0, 0.01);
		border-radius: 24rpx;
		padding: 32rpx;
		margin-bottom: 20rpx;
	}

	.item-top {
		display: flex;
		justify-content: space-between;
		padding-bottom: 24rpx;
		border-bottom: 2rpx solid #EEEEEE;

		.course-title {
			font-size: 30rpx;
			color: #2F1F1A;
			line-height: 42rpx;
			font-weight: bold;
		}

		.course-time {
			font-size: 24rpx;
			color: #333333;
		}
	}

	.item-bottom {
		font-size: 26rpx;
		color: #999999;
		padding-top: 30rpx;

		.bottom-info {
			margin-bottom: 16rpx;

			.value {
				margin-left: 10rpx;
				color: #333333;
			}
		}
	}
</style>